package com.example.tengoos.constants;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.http.HttpProtocol;
import com.qcloud.cos.region.Region;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


/**
 * @author 大忽悠
 * @create 2022/3/6 11:59
 */
@Component
@Slf4j
public class TengOosConstans {
    public static final COSClient cosClient;
    public static final String APPID="-1304941286";
    /**
     * 本地上传文件的查询路径
     */
    public static final String WINDOWS_FILE_UPLOAD="D:/oos-upload/";
    /**
     * 下载文件到本地的存放路径
     */
    public static final String WINDOWS_FILE_STORAGE="D:/oos-download/";
    /**
     * 桶名
     */
    public static String BUCKETNAME;
    /**
     * 存储桶名称，格式：BucketName-APPID
     */
    public static String REAL_BUCKET_NAME=BUCKETNAME+APPID;
    static {
        final String SECRETID = "AKIDjGXYIlyuZx6xXqseT2OVLvFI5bqoXzA4";
        final String SECRETKEY = "h8IDtIQIuGL9gwvxlIZaLp2yd18yXnlT";
        final String REGION = "ap-nanjing";
        final COSCredentials cred = new BasicCOSCredentials(SECRETID, SECRETKEY);
        Region region = new Region(REGION);
        ClientConfig clientConfig = new ClientConfig(region);
        clientConfig.setHttpProtocol(HttpProtocol.https);
        cosClient = new COSClient(cred, clientConfig);
    }

    public void setBucketName(@Value("${BUCKETNAME}")String bucketName1)
    {
        BUCKETNAME=bucketName1;
    }
}
